import java.lang.reflect.Method;

/**
 * @author: xinmi
 * @date: 2020/11/2
 * @description:
 */

class ClassA {
    private String name = "John";
    public String returnName() {
        return name;
    }
}

public class MethodDemo {
    public static void main(String[] args) throws Exception {
        Class c = ClassA.class;
        Method[] methods = c.getDeclaredMethods();
        ClassA obj = new ClassA();
        for (Method m : methods) {
            System.out.println("method Name: " + m.getName());
            Object result = m.invoke(obj, new Object[0]);
            System.out.println(m.getName() + ": " + result);
        }
    }
}
